<template>
  <span style="font-size: 16px;color: lawngreen">今日已看诊{{ number }}人</span>
  &nbsp;&nbsp;&nbsp;&nbsp;
  <span style="font-size: 16px;color: red">当前有{{ total }}人排队</span>
  <hr/>
  <div style="text-align: left">检查申请</div>
  <hr/>
  <el-form :inline="true" :model="formNoCheck">
    <el-form-item label="病历号">
      <el-input  placeholder="请输入患者病历号" clearable  v-model="formNoCheck.caseNumber"/>
    </el-form-item>
    <el-form-item label="患者姓名">
      <el-input  placeholder="请输入患者姓名" clearable v-model="formNoCheck.realName"/>
    </el-form-item>
    <el-form-item>
      <el-button type="success" @click="queryCheckList">查询</el-button>
    </el-form-item>

  </el-form>
  <hr/>
  <el-table :data="noCheckList" style="width: 100%">
    <el-table-column prop="id" label="编号" width="80px"/>
    <el-table-column prop="caseNumber" label="病历号"/>
    <el-table-column prop="realName" label="患者姓名" />
    <el-table-column prop="techName" label="检查项" />
    <el-table-column label="操作" >
      <template #default="{ row }">
        <el-button type="primary" round
                   @click="checkRecord(row)">进行检查</el-button>
        <el-button type="success" round>跳过</el-button>
        <el-button type="info" round>叫号</el-button>
      </template>

    </el-table-column>
  </el-table>
  <hr/>
  <!-- 分页插件 -->
  <div class="example-pagination-block">
    <el-pagination layout="prev, pager, next" :total="total" />
  </div>

</template>

<script setup>
import {useRoute} from "vue-router";
import {computed, onMounted, reactive, ref} from "vue";
import axios from "axios";
import {ElMessage} from "element-plus";
import {forEach} from "core-js/stable/dom-collections";

//定义某个医生当日已检查人数
const number=ref(0);
//定义某个医生当前待检查人数
const total=ref(0)
//声明分页总记录数
//定义查询待检查人员查询表单
const formNoCheck=reactive({
  caseNumber:'',
  realName:''
});

//声明待检查人员列表
const noCheckList=ref([]);

onMounted(()=>{
  loadNoCheckList();
});

function loadNoCheckList(){
  axios.get("http://localhost/his/queryNoCheckList")
      .then((response)=>{
        noCheckList.value=response.data.registers;
        total.value=response.data.total;
      })
      .catch((error)=>{
        console.log(error);
      });
}

/*定义函数提交病历号和患者姓名查询待检查列表*/
function queryCheckList(){
  axios.get("http://localhost/his/queryNoCheckList?caseNumber="
      +formNoCheck.caseNumber+"&realName="+formNoCheck.realName)
      .then((response)=>{
        noCheckList.value=response.data.registers;
        total.value=response.data.total;
      })
      .catch((error)=>{
        console.log(error);
      });
}

/*进行检查等级*/
function checkRecord(row){
  sessionStorage.setItem("id",JSON.stringify({id:row.id,cid:row.cid}));

}
</script>

<style scoped>

</style>